package _spring_test._cache;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author: huangya
 * @Date: 2020/6/20
 * @Description:
 */
public class CacheTest {

    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("cache/application-cache.xml");
        IAccountService accountService = (IAccountService) ac.getBean("accountService");
        // 第一次查询，应该走数据库
        System.out.println("first query...");
        Account account = accountService.getAccountByName("hy");
        // 第二次查询，应该不查数据库，直接返回缓存的值
        System.out.println("second query...");
        Account account1 = accountService.getAccountByName("hy");
//        Account account2 = accountService.getAccountByName("hy2");
        System.out.println("---------------");
    }
}
